import Vue from "vue"
import VueRouter from "vue-router"

Vue.use(VueRouter)

const routes = [{
    path: "/home",//首页
    alias: "/",
    name: "home",
    component: () => import("@/pages/home/home")
}, {
    path: "/list",//列表页
    name: "list",
    component: () => import("@/pages/list/list")
}, {
    path: "/shopcar",//购物车
    name: "shopcar",
    component: () => import("@/pages/shopcar/shopcar")
}, {
    path: "/user",//用户中心
    name: "user",
    component: () => import("@/pages/user/user")
}, {
    path: "/details",//详情页
    name: "details",
    component: () => import("@/pages/details/details"),
    props: (route) => {
        return {
            id: route.query.id
        }
    }
},{
    path: "/register",//注册页
    name: "register",
    component: () => import("@/pages/register/register")
}, {
    path: "/login",//登录页
    name: "login",
    component: () => import("@/pages/login/login")
},{
    path: "/test",//测试页
    name: "test",
    component: () => import("@/pages/test")
}]

export default new VueRouter({
    routes,
    scrollBehavior() {//滚动行为，回到顶部
        return { x: 0, y: 0 }
    }
})